#include "server.h"

char* login(int netfd, MYSQL* conn){
    char* username = (char*)malloc(32);
    int userOpt;
    int ret = recv(netfd, &userOpt, sizeof(userOpt), 0);
    //printf("server receive opt = %d\n", userOpt);
    if(userOpt == 0){  //登录
        printf("%d netfd start login.\n", netfd);
        username = loginVerify(netfd, conn);
        //printf("username = %s\n", username);
    }else if(userOpt == 1){  //注册
        printf("%d netfd start regis.\n", netfd);
        regisUser(netfd, conn);
        recv(netfd, &ret, 4, 0);
        if(ret == 1){
            username = loginVerify(netfd, conn);
            //printf("username = %s\n", username);
        }
    }
    return username;
}